package com.example;

import com.example.entity.Emp;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class RedisTestSerice {
    @Cacheable(cacheNames = "emps")
    public List getEmpList(){
        System.out.println("正在从数据库中获取信息");
        List<String> emps = List.of("张三","李四","王五");
        System.out.println("已从数据库中获取信息");
        return emps;
    }
    @CachePut(cacheNames = "emp")
    public Emp TestAdd(Emp emp){
        System.out.println("数据已添加");
        return emp;
    }
    @CacheEvict(cacheNames = "emp")
    public Emp Testdel(Emp emp){
        System.out.println("删除成功");
        return emp;
    }
}
